package com.onlyyou.custom.VO;

import com.onlyyou.custom.enums.ResultEnum;
import lombok.Data;

/**
 * @Author: 小野
 * @Date: 2020/1/12 15:52
 * 返回参数封装类
 */
@Data
public class ResultVO {
    private Integer status;
    private String msg;
    private Object data;

    public static ResultVO success(Object data) {
        return new ResultVO(200, "ok", data);
    }

    public static ResultVO success() {
        return success(null);
    }

    public static ResultVO error(Integer status, String msg, Object data) {
        return new ResultVO(status,msg,data);
    }

    public ResultVO(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public ResultVO(ResultEnum resultEnum, Object data){
        this.status=resultEnum.getStatus();
        this.msg=resultEnum.getMsg();
        this.data=data;
    }
}
